using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Irc.Objects;
using Irc.Events;

namespace Irc.Net
{
	public partial class MessageTab : UserControl
	{
		private Nickname nicknameObject;
		public Nickname Target
		{
			get { return nicknameObject; }
		}
		public MessageTab(Nickname target)
		{
			InitializeComponent();
			nicknameObject = target;
			Dock = DockStyle.Fill;
			CommandText.Name = Name + "-" + CommandText.Name;
			CommandText.KeyDown += Main.ParseCommand;
		}
		public void AddMessage(Irc.Objects.Message message)
		{
			if(MessageText.Created)
				MessageText.Invoke((MethodInvoker)delegate {
					MessageText.AppendMessage(message);
				});
			Refocus();
		}
		public void Refocus()
		{
			if(CommandText.Created)
				CommandText.BeginInvoke((MethodInvoker)delegate { CommandText.Focus(); });
		}
	}
}
